<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>具名插槽</title>
</head>
<body>
  <div id="app">
    {{message}}
    <cpn></cpn>
    <cpn>我只会替换没有名字的</cpn>
    <cpn>
      <span slot="left">返回</span>
      <span slot="center">（使用具名插槽-精准找到中间插入）</span>
    </cpn>
  </div>

  <template id="cpn">
    <div>
      <h2>我是一个子组件</h2>
      <slot name="left"><span>左边的</span></slot>   <!--这里的slot之间可以放默认值-->
      <slot name="center"><span>中间的</span></slot>
      <slot name="right"><span>右边的</span></slot>
      <slot>我是默认值</slot>
    </div>
  </template>

  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        message: '你好啊',
      },
      components: {
        cpn: {
          template: '#cpn'
        }
      }
    })
  </script>
</body>
</html>